package org.yray.io.sentinel.controller;

import io.etcd.jetcd.ByteSequence;
import io.etcd.jetcd.Client;
import io.etcd.jetcd.KV;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;



@RestController
@RequestMapping("/test")
@Slf4j
public class TestController  {



    @Autowired(required = false)
    Client client;

    @PostMapping(value = "/toEtcd", produces = "application/json;charset=UTF-8")
    public void getSceneInfo(@RequestParam(value = "key") String key,@RequestParam(value = "value") String value )
    {
        KV kvClient = client.getKVClient();
        ByteSequence keySeq = ByteSequence.from(key.getBytes());
        ByteSequence valueSeq = ByteSequence.from(value.getBytes());
        kvClient.put(keySeq, valueSeq);

    }

}
